<?php
/**
*Smarty plugin
*@Liu Zhongjie
*@Beijing Arouter Co.Ltd
*@2007-2-12
**/

/**
* Smarty {html_button} function plugin
*
* Type:    function<br>
* Name:    html_button<br>
* Date:    Feb 12,2007<br>
* Input:<br>
*         -name        = Button name.(string).
*         -value       = Button value.(string).
*         -type        = Button type.Their are three types:submit/reset/button,default submit.(string).
*         -class       = Class CSS style.(string).
*
* Examples:
* <pre>
* {html_button name="submit" value="login" class="button"}
* {html_button type="reset" name="reset" value="clear" class="button"}
* {html_button type="button" name="button1" value="display" class="button"}
* </pre>
* @param array
* @param Smarty
* @return string
**/

function smarty_function_html_button ($params, &$smarty)
{
	require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
	
	$name         = NULL;
	$value        = NULL;
	$type         = "submit";
	$class        = NULL;
	$label        = false;
    $extra        = '';
    
    foreach ($params as $_key=>$_value) {
        switch ($_key) {
            case 'name':
            case 'value':
            case 'type':
            case 'class':
                $$_key = (string)$_value;
                break;
                
            case 'label':
                $$_key = (bool)$_value;
                break;

        }
    }
  

    if($label) $output = "<label>";
    else $output = "";
    $output .= '<input type="' . smarty_function_escape_special_chars($type) .'" name="' 
    . smarty_function_escape_special_chars($name) . '" value="' 
    . smarty_function_escape_special_chars($value) . '" class="' 
    . smarty_function_escape_special_chars($class) . '" ' ;

    $output .=$extra . ' />' ;
    if($label) $output .= "</label>";
    
    return $output;
}
?>